package com.vanysoft.business.data.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.vanysoft.business.data.dao.PlantUserMapper;
import com.vanysoft.business.data.entity.PlantUser;
import com.vanysoft.business.data.service.PlantUserService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 工厂人员信息管理 服务实现类
 * </p>
 *
 * @author YangLei
 * @since 2018-07-01
 */
@Service
public class PlantUserServiceImpl extends ServiceImpl<PlantUserMapper, PlantUser> implements PlantUserService {

    @Override
    public PlantUser selectOne(PlantUser plantUser) {
        PlantUser entity = selectOne(new EntityWrapper<PlantUser>()
                .eq("plant_code", plantUser.getPlantCode())
                .eq("procurement_manager", plantUser.getProcurementManager())
                .eq("procurement_user", plantUser.getProcurementUser()));
        return entity;
    }

    @Override
    public Page<PlantUser> selectPage(Page<PlantUser> page, String plant, String user, int status, String language) {
        Map<String, Object> map = new HashMap<>();
        map.put("plant", plant);
        map.put("user", user);
        map.put("status", status);
        map.put("lang", language);
        List<PlantUser> list = baseMapper.selectPage(page, map);
        page.setRecords(list);
        return page;
    }
}
